<?php
    echo $this->Html->css(array(
    	'jquery/jqgrid/4.6.0/ui.jqgrid'
    ), array('inline'=>false));
    
    echo $this->Html->script(array(
        'jquery/jqgrid/4.6.0/grid.locale-es',
        'jquery/jqgrid/4.6.0/jquery.jqGrid.min',
       	'app/lib_funcionesAjax',
        'app/ordenesTrabajo/lib_ordenesTrabajoGestion'
    ), array('inline'=>false));
    
    $anchoTabla = 1250;
?>
<script type="text/javascript">
$(window).load(function(){
	anchoTabla = <?php echo $anchoTabla; ?>;
	ordenesArrayJSON = <?php echo json_encode($ordenesArrayJSON); ?>;
    fnInicializarTabla("#listaOrdenes");
});
</script>
<?php if(isset($msjRegistroOrden)) {?>
<script type="text/javascript">
jAlert('<?php echo $msjRegistroOrden; ?>',TITULO_MENSAJE);
</script>
<?php }?>
<div class="subtitulo">
	<div class="divBannerCabecera" align="left">
		<table border="0" cellpadding="1">
			<tr>
			<td><img src="<?php echo Router::url('/img/iconos/icono_orden_trabajo.png',false); ?>" width="45" height="45" border="0" alt="" title="" /></td>
			<td width="3%"></td>
			<td>Consulta de &Oacute;rdenes</td>
			</tr>
		</table>
	</div>
</div>
<br />
<fieldset class="fieldsetForm">
	<legend class="ui-widget-header">Datos de B&uacute;squeda</legend>
	<div align="center">
	<form id="formBusqueda" name="formBusqueda" action="<?php echo Router::url("/OrdenesTrabajo/consultar_ordenes"); ?>" method="post">
		<table border="0">
			<tr>
				<td align="right">Nro. Orden : </td>
				<td align="left"><input type="text" id="nroOrden" name="nroOrden" value="<?php echo $condiciones["nroOrden"]; ?>" /></td>
				<td align="center" width="1%"></td>
				<td align="right">RUC / DNI : </td>
				<td align="left"><input type="text" id="rucDni" name="rucDni" value="<?php echo $condiciones["rucDni"]; ?>" /></td>
				<td align="center" width="1%"></td>
				<td align="right">Cliente</td>
				<td align="left">
					<select name="idCliente" id="idCliente">
						<option value="">[Todos]</option>
						<?php 
						$dimClientes = count($clientes);
						$selected = "";
						for($i = 0;$i<$dimClientes;$i++){ 
							$objCliente = $clientes[$i]["Cliente"];
							
							if($objCliente["idCliente"] == $condiciones["idCliente"]){
								$selected="selected='selected'";
							}else{
								$selected="";
							}
						?>
						<option value="<?php echo $objCliente["idCliente"];?>" <?php echo $selected;?>><?php echo $objCliente["nombreEntidad"]; ?></option>
						<?php } ?>
						
						<?php if($dimClientes == 0){?>
						<option value="">[Ninguno]</option>
						<?php } ?>
					</select>
				</td>
				<td align="center" width="1%"></td>
				<td align="center"></td>
			</tr>
			<tr>
				<td align="right">Placa : </td>
				<td align="left">
					<input type="text" id="numeroPlaca" name="numeroPlaca" value="<?php echo $condiciones["numeroPlaca"]; ?>" />
				</td>
				<td align="center" width="1%"></td>
				<td align="right">Marca : </td>
				<td align="left">
					<select name="idMarcaVehiculo" id="idMarcaVehiculo">
						<option value="">[Todos]</option>
						<?php 
						$dimMarcas = count($marcasVehiculos);
						$selected = "";
						for($i = 0;$i<$dimMarcas;$i++){ 
							$objMarca = $marcasVehiculos[$i]["CatalogoDetalle"];
							
							if($objMarca["idItem"] == $condiciones["idMarcaVehiculo"]){
								$selected="selected='selected'";
							}else{
								$selected="";
							}
						?>
						<option value="<?php echo $objMarca["idItem"];?>" <?php echo $selected; ?>><?php echo $objMarca["descripcion"]; ?></option>
						<?php } ?>
					</select>
				</td>
				<td align="center" width="1%"></td>
				<td align="right">Modelo : </td>
				<td align="left">
					<input type="text" id="modelo" name="modelo" value="<?php echo $condiciones["modelo"]; ?>" />
				</td>
				<td align="center" width="1%"></td>
				<td align="center">
					<input id="btnBuscar" type="button" value="Buscar"
						onclick="fnBuscar();" class="btn btnposicion"
	   					style="background-image: url(<?php echo Router::url('/img/iconos/buscar.png',false); ?>)" />
				</td>
			</tr>
		</table>
	</form>
	</div>
</fieldset>
<br />
<div class="barraHerramientas" style="width:<?php echo $anchoTabla?>px;">            
    <input type="button" value="Agregar"
			onclick="fnNuevaOrden();" class="btn btnposicion"
			style="background-image: url(<?php echo Router::url('/img/iconos/agregar.png',false); ?>)" />
		   			
	<input type="button" value="Editar"
			onclick="fnEditarOrden();" class="btn btnposicion"
			style="background-image: url(<?php echo Router::url('/img/iconos/editar.png',false); ?>)" />
			
	<input type="button" value="Verificar"
			onclick="fnVerificarOrden();" class="btn btnposicion"
			style="background-image: url(<?php echo Router::url('/img/iconos/verificar.png',false); ?>)" />
		   			
	<input type="button" value="Anular"
			onclick="fnAnularOrden();" class="btn btnposicion"
			style="background-image: url(<?php echo Router::url('/img/iconos/anular.png',false); ?>)" />
			
	<input type="button" value="Imprimir"
			onclick="fnImprimir();" class="btn btnposicion"
			style="background-image: url(<?php echo Router::url('/img/iconos/impresora.png',false); ?>)" />
</div>
<div id="divTablaOrdenes" align="center">
	<table id="listaOrdenes"></table>
	<div id="pagerOrdenes"></div>
</div>